#include <iostream>
#include <cstring>
#include <string>
#include <iomanip>
#include <cstdio>

using namespace std;

void cntRegion(long long bb, int r) {
	if (r == 0) {
		cout << setw(11) << right << bb-1 << endl;
		for (int i=0; i<9; ++i)
			cout << setw(11) << right << 0 << endl;
	}
	else {
		for (int i=0; i<10; ++i) {
			if (i==r) cout << setw(11) << right << bb << endl;
			else cout << setw(11) << right << 0 << endl;
		}
	}
}

void cntNormal(long long bb, int whichD, int r) {
	long long left, right;
	left = right = 0;
	char buf[10];
	memset(buf, 0, 10);
	sprintf(buf, "%09lld", bb);
	for (int i=0; i<9; ++i) {
		if (i<whichD)
			left = left*10 + buf[i]-'0';
		else if (i>whichD)
			right = right*10 + buf[i]-'0';
	}
	int d = buf[whichD]-'0';
	long zeros = 1;
	for (int i=0; i<8-whichD; ++i)
		zeros *= 10;
	bool first = true;
	for (int i=0; i<d; ++i) {
		if (first && r == 0) 
			cout << setw(11) << std::right << (left+1)*zeros - 1<< endl;
		else
			cout << setw(11) << std::right << (left+1)*zeros << endl;
		first = false;
	}
	if (first && r == 0) 
		cout << setw(11) << std::right << left*zeros + right -1 << endl;
	else
		cout << setw(11) << std::right << left*zeros + right << endl;
	first = false;

	for (int i=d+1; i<10; ++i)
		cout << setw(11) << std::right << left*zeros << endl;
}

int main(void)
{
	bool firstblood = true;
	while (true) {
		long long bb;
		int whichD;
		cin >> bb >> whichD;
		if (bb == 0 && whichD == 0) break;
		if (!firstblood) cout << endl;
		int region = (bb/10000000)%10;
		bb = (bb/100000000)*10000000+bb%10000000;
		if (whichD == 3) {
			cntRegion(bb, region);
		}
		else {
			if (whichD>3) --whichD;
			--whichD;
			cntNormal(bb, whichD, region);
		}
		firstblood = false;
	}
	return 0;
}